import java.io.*;
import java.util.Scanner;

public class MyHead {
    public static void main(String args[]) {
        int n = -1;
        Scanner sc = new Scanner(System.in);
        System.out.println("how many lines?");
        n = sc.nextInt();
        byte[] a = new byte[100];
        byte[] line = "\r\n".getBytes();
        try {
            File f = new File("5316.txt");
            File fout = new File("5316.bin");
            FileOutputStream fos = new FileOutputStream(fout);
            DataOutputStream outData = new DataOutputStream(fos);
            Reader in = new FileReader(f);
            BufferedReader bufferRead = new BufferedReader(in);
            String str = null;
            while (n != 0 && (str = bufferRead.readLine()) != null) {
                System.out.println(str);
                outData.writeChars(str);
                outData.writeChars("\r\n");
                n--;
            }
            in.close();
        } catch (IOException e) {
            System.out.println("File read Error" + e);
        }
        try {
            File file = new File("5316.bin");
            File fout = new File("5316_2.txt");
            FileInputStream fis = new FileInputStream(file);
            DataInputStream inData = new DataInputStream(fis);
            n = 10;
            int temp,j=0;
            String s = "";
            char ch='\0';
            while ((ch=inData.readChar())!='\0') {
                if(ch=='\r'||ch=='\n'){
                    if(ch=='\r'){
                        System.out.printf("\n");
                    }
                    continue;
                }
                System.out.print(ch);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
